import {
    groupList,
    groupPage,
    groupAdd,
    groupUpdate,
    groupDelete
} from '@/api/base.group'
export default {
    namespaced: true,
    //数据保存在State中
    state: {
        menu: []
    },
    //对于后台的请求放在actions中
    actions: {
        getGroupList() {
            return new Promise((resolve, reject) => {
                groupList().then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        //context 对象是vuex框架自己放入到第一个参数,界面上调用时传入的参数,需要放入第二个参数
        getGroupPage(context, data) {
            return new Promise((resolve, reject) => {
                groupPage(data).then(
                    res => {
                        resolve(res)
                    }
                )
            })
        },
        addgroup(context, data) {
            return new Promise((resolve, reject) => {
                console.log('addgroup')
                console.log(data)
                groupAdd(data).then(
                    resolve()
                )
            })
        },

        updategroup(context, data) {
            return new Promise((resolve, reject) => {
                console.log('updategroup')
                console.log(data)
                groupUpdate(data).then(
                    resolve()
                )
            })
        },

        deletegroup(context, id) {
            return new Promise((resolve, reject) => {
                groupDelete(id).then(
                    resolve()
                )
            })
        }
    }
}